package com.ly.work.zk;

//偶数线程
public class EvenThread extends Thread {

    //重写run方法

    @Override
    public void run() {
        while (Main.i<=100){
            synchronized (Main.class) {
                if (Main.i%2==0){
                    System.out.println(Thread.currentThread().getName()+"==偶数=="+Main.i);
                    Main.i++;
                    try {
                        Main.class.notify();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }else {
                    try {
                        Main.class.wait();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
}
